package com.audaque.springboot.foshanupload.casclientautoconfigsupport.config;

import com.audaque.springboot.foshanupload.casclientautoconfigsupport.properties.ServerProperties;
import com.audaque.springboot.foshanupload.casclientautoconfigsupport.properties.ServiceProperties;
import com.audaque.springboot.foshanupload.casclientautoconfigsupport.strategy.UnAuthenticationRedirectStrategy;
import com.audaque.springboot.foshanupload.core.properties.StaticResourcePathProperties;
import net.unicon.cas.client.configuration.CasClientConfigurerAdapter;
import net.unicon.cas.client.configuration.EnableCasClient;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Configuration;

import java.util.Map;

/**
 * @author zgb
 * @desc cas过滤器注入：方式1  继承   CasClientConfigurerAdapter implements CasClientConfigurer
 * @date 2022-12-12 12:30:53
 */
/*
@Configuration
public class CasClientConfigurerAdapterConfig extends CasClientConfigurerAdapter {
    @Autowired
    private ServerProperties serverProperties;
    @Autowired
    private ServiceProperties serviceProperties;

    @Autowired
    private StaticResourcePathProperties staticResourcePathProperties;
    @Override
    public void configureAuthenticationFilter(FilterRegistrationBean authenticationFilter) {
        super.configureAuthenticationFilter(authenticationFilter);
        Map<String, String> initParameters = authenticationFilter.getInitParameters();
        initParameters.put("authenticationRedirectStrategyClass",
                UnAuthenticationRedirectStrategy.class.getName());
        //忽略认证的路径
        String ignorePattern = StringUtils.join(staticResourcePathProperties.getList(), "|");
        String dynamicResourceIgnorePattern = serviceProperties.getDynamicResourceIgnorePattern();
        ignorePattern = ignorePattern + "|" + dynamicResourceIgnorePattern;
        initParameters.put("ignorePattern", ignorePattern);
    }

    @Override
    public void configureValidationFilter(FilterRegistrationBean validationFilter) {
        super.configureValidationFilter(validationFilter);
        Map<String, String> initParameters = validationFilter.getInitParameters();
        initParameters.put("encodeServiceUrl", "false");
    }


}
*/
